home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / computerjanitor / file_cruft_tests.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  3.2 KB  |  63 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. import subprocess
  6. import tempfile
  7. import unittest
  8. import computerjanitor
  9.  
  10. class FileCruftTests(unittest.TestCase):
  11.     
  12.     def setUp(self):
  13.         (fd, self.pathname) = tempfile.mkstemp()
  14.         os.write(fd, 'x' * 1024)
  15.         os.close(fd)
  16.         self.cruft = computerjanitor.FileCruft(self.pathname, 'description')
  17.  
  18.     
  19.     def tearDown(self):
  20.         if False and os.path.exists(self.pathname):
  21.             os.remove(self.pathname)
  22.         
  23.  
  24.     
  25.     def testReturnsCorrectPrefix(self):
  26.         self.assertEqual(self.cruft.get_prefix(), 'file')
  27.  
  28.     
  29.     def testReturnsCorrectPrefixDescription(self):
  30.         self.assertEqual(self.cruft.get_prefix_description(), 'A file on disk')
  31.  
  32.     
  33.     def testReturnsCorrectShortname(self):
  34.         self.assertEqual(self.cruft.get_shortname(), self.pathname)
  35.  
  36.     
  37.     def testReturnsCorrectName(self):
  38.         self.assertEqual(self.cruft.get_name(), 'file:%s' % self.pathname)
  39.  
  40.     
  41.     def testReturnsCorrectDescription(self):
  42.         self.assertEqual(self.cruft.get_description(), 'description\n')
  43.  
  44.     
  45.     def testReturnsCorrectDiskUsage(self):
  46.         p = subprocess.Popen([
  47.             'du',
  48.             '-s',
  49.             '-B',
  50.             '1',
  51.             self.pathname], stdout = subprocess.PIPE)
  52.         (stdout, stderr) = p.communicate()
  53.         du = int(stdout.splitlines()[0].split('\t')[0])
  54.         self.assertEqual(self.cruft.get_disk_usage(), du)
  55.  
  56.     
  57.     def testDeletesPackage(self):
  58.         self.assert_(os.path.exists(self.pathname))
  59.         self.cruft.cleanup()
  60.         self.assertFalse(os.path.exists(self.pathname))
  61.  
  62.  
  63.